package com.eastfair.transport.controller;

import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.transport.service.TransportExhibitionCompanyService;
import com.eastfair.venueservice.vo.ExhibitionCompanyVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 展会企业 controller.
 *
 * @author dqq
 * @date 2022 /10/11
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/exhibitionCompany")
public class ExhibitionCompanyController {

    @Resource
    private TransportExhibitionCompanyService transportExhibitionCompanyService;

    /**
     * 服务商ID查询展会企业VO.
     *
     * @param serviceProviderId the service provider id
     * @param exhibitionMangeId the exhibition mange id
     * @return the by service provider id
     */
    @ApiOperation("服务商ID查询展会企业VO")
    @GetMapping("/serviceProvider/get")
    public R<ExhibitionCompanyVO> getByServiceProviderId(@RequestParam("serviceProviderId") Long serviceProviderId,
                                                         @RequestParam("exhibitionMangeId") Long exhibitionMangeId) {
        log.info("getByServiceProviderId - 服务商ID查询展会企业VO, serviceProviderId={}, exhibitionMangeId={}", serviceProviderId, exhibitionMangeId);
        try {
            return R.successDef(transportExhibitionCompanyService.getByServiceProviderId(serviceProviderId, exhibitionMangeId));
        } catch (BizException e) {
            return R.fail(e);
        }
    }
}